#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str;
	cin >> str;
	int remainber = 0;
	for (char c : str)
	{
		int digiht = c - '0';
		remainber = (remainber * 10 + digiht) % 7;
	}

	cout << remainber << endl;
	return 0;
}